/**
* 
* ====================================================================
*
* @author apov <apov@ymail.com>
*/ 
#pragma once

#include <BaseDefine.h>
#include "MySQL_DBSession.h"
#include "MySQL_DBResultSet.h"
#include "DBStatement.h"

/**
* @class DBStatement
*  - 
*/ 
class MySQL_DBStatement : public DBStatement{
	enum{
		DEF_MAX_BIND=		2,
	};

public:
	virtual int executeUpdate();
	virtual DBResultSet* executeQuery();
	virtual int prepare( int result_type );
	virtual void reset();	
	virtual DBSession* getSession();

	virtual void setByte( char& value, short flag );
	virtual void set2Byte( short& value, short flag );
	virtual void set4Byte( int& value, short flag );	
	virtual void set4Byte( unsigned int& value, short flag );	
	virtual void set8Byte( __int64& value, short flag );	
	virtual void setFloat( float& value, short flag );
	virtual void setString( char* value, short flag, int size = 0 );		
	virtual void setDate( char* value, short flag );
	virtual void setMemory( char* value, int size, short flag );
	virtual void setNull();
	virtual void setReal( double& value, int precision, int scale, short flag );
	virtual int is_procedure();

	MySQL_DBStatement( MySQL_DBSession* session );
	virtual ~MySQL_DBStatement();

protected:

private:
	bool prepareStmt();
	void error_log( char* method, int line );

	MySQL_DBResultSet result_set_;	

	MYSQL_STMT* stmt_;
	MYSQL_BIND binds_[ DEF_MAX_BIND ];
	unsigned long bind_length_[ DEF_MAX_BIND ];
	int bind_cursor_;
	int param_count_;

	//err
	MYSQL_RES* prepare_meta_result_;
};
